#! /usr/bin/env python

EXTRA_DEFINES = []

if bld.env.PLATFORM in ('arm64-ios', 'x86_64-ios'):
    # Note: LUA_NO_SYSTEM is our own invention, mimicking the LJ_NO_SYSTEM
    EXTRA_DEFINES = ['LUA_NO_SYSTEM']

lua_lib_source = ['lapi.c', 'lcode.c', 'ldebug.c', 'ldo.c',
                  'ldump.c', 'lfunc.c', 'lgc.c', 'llex.c',
                  'lmem.c', 'lobject.c', 'lopcodes.c', 'lparser.c',
                  'lstate.c', 'lstring.c', 'ltable.c', 'ltm.c',
                  'lundump.c', 'lvm.c', 'lzio.c', 'lauxlib.c',
                  'lbaselib.c', 'ldblib.c', 'liolib.c',
                  'lmathlib.c', 'loslib.c', 'ltablib.c',
                  'lstrlib.c', 'loadlib.c', 'linit.c']

lua_lib = bld.stlib(features = 'c cxx',
                    name = 'lua_static',
                    includes = '. ../',
                    target = 'lua',
                    source = lua_lib_source,
                    defines = ['LUA_ANSI'] + EXTRA_DEFINES)

if bld.env.IS_TARGET_DESKTOP:
    lua = bld.program(features = 'c cxx',
                      includes = '. ../',
                      source = 'lua.c',
                      target = 'lua',
                      use = 'lua_static',
                      defines = ['LUA_ANSI'] + EXTRA_DEFINES)

    luac = bld.program(features = 'c cxx',
                       includes = '. ../',
                       source = 'luac.c print.c',
                       target = 'luac',
                       use = 'lua_static',
                       defines = ['LUA_ANSI'] + EXTRA_DEFINES)

bld.install_files('${PREFIX}/include/lua', 'lua.h')
bld.install_files('${PREFIX}/include/lua', 'lauxlib.h')
bld.install_files('${PREFIX}/include/lua', 'lualib.h')
bld.install_files('${PREFIX}/include/lua', 'luaconf.h')
